import { defineStore } from "pinia"
import { computed, ref } from "vue"

// 通过 defineStore 定义数据仓库，返回获取仓库的函数，命名一般是 useXxxStore
export const useCounterStore = defineStore("counter", () => {

  const totalCount = ref(0)

  //修改数据
  const addTotalCount=(value:number)=>{
    totalCount.value+=value
  }

  const dobuleTotalCount=computed(()=>{
    return totalCount.value*2
  })
  // 返回数据
  return { totalCount,addTotalCount,dobuleTotalCount }
},{persist:true})